package gam.n1.ask;

import gam.n1.ent.AEntity;
import org.bukkit.Location;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;

import java.util.function.Supplier;

public class AskEntity implements Listener, Supplier<Entity> {
    private volatile Entity a = null;
    @EventHandler(priority = EventPriority.HIGHEST)
    public void a(PlayerInteractEntityEvent var1){
        if (Asking.isAsking(var1.getPlayer().getUniqueId())){
            Entity var2 = var1.getRightClicked();
            if (a == null && var2 instanceof AEntity) a = var2;
            var1.setCancelled(true);
            HandlerList.unregisterAll(this);
        }
    }
    @Override
    public Entity get() {
        while (a == null);
        return a;
    }
}
